<html>
<head>
<META http-equiv="Content-Type" content=text/html; charset=UTF-8>
<Meta Name="KEYWORDS" CONTENT="web hosting">
<title>free webhosting</title>
<style>
<!--
body,td,a,p,.h {
	font-family: arial, sans-serif;
}

.h {
	font-size: 20px;
}

.q {
	color: #0000cc;
}
//
-->
</style>
</head>
<body bgcolor=#000000>
	<center>



<?php
// print_r($_FILES);
include_once 'gencode.php';
echo '<font size=3 color=#ff6600>File uploaded! <br>';

$save_solution_mysql = true;

if ($_FILES ["file"] ["size"] < 2000000) // 200KB
{
	if ($save_solution_mysql) {
		$myfile = $_FILES ["file"] ["tmp_name"];
		$fp = fopen ( $myfile, "rb" );
		if (! $fp)
			die ( "file open error" );
		$file_data = addslashes ( fread ( $fp, filesize ( $myfile ) ) );
		fclose ( $fp );
		unlink ( $myfile );
		$file_name = $_FILES ["file"] ["name"];
		$file_size = $_FILES ["file"] ["size"];
		$file_type = $_FILES ["file"] ["type"];
		$filemd5 = md5 ( $file_data );
		$code = GenCode ();
		if (InsertFileCacheRecord ( $file_data, $file_name, $file_size, $filemd5,$file_type, $code ))
		{
			echo "Upload: " . $_FILES ["file"] ["name"] . "<br />";
			echo "Type: " . $_FILES ["file"] ["type"] . "<br />";
			echo "Size: " . ($_FILES ["file"] ["size"] / 1024) . " Kb<br />";
			echo 'Link URL: <a href="'.$Server_Address.'/link.php?ref=' . urlencode($code)  . '">'.$Server_Address.'/link.php?ref=' . urlencode($code) . '</a><br>';
			echo 'BB CODE: [url]'.$Server_Address.'/link.php?ref=' . $code . ' [/url]';
		}
		else {
			echo 'Upload Failed. ERROR 1001';
		}
		
	} else {
		if ($_FILES ["file"] ["error"] > 0) {
			echo "Return Code: " . $_FILES ["file"] ["error"] . "<br />";
		} else {
			echo "Upload: " . $_FILES ["file"] ["name"] . "<br />";
			echo "Type: " . $_FILES ["file"] ["type"] . "<br />";
			echo "Size: " . ($_FILES ["file"] ["size"] / 1024) . " Kb<br />";
			echo "Temp file: " . $_FILES ["file"] ["tmp_name"] . "<br />";
			
			if (file_exists ( "upload/" . $_FILES ["file"] ["name"] )) {
				echo $_FILES ["file"] ["name"] . " already exists. ";
			} else {
				$code = GenCode ();
				mkdir ( 'upload/' . $code );
				$newpath = "upload/" . $code . '/' . $_FILES ["file"] ["name"];
				move_uploaded_file ( $_FILES ["file"] ["tmp_name"], $newpath );
				echo "Stored in: " . $newpath . '<br>';
				InsertFileRecord ( $newpath, $code );
				echo 'Link URL: http://www.jandown.com/link.php?ref=' . urlencode($code) . '<br>';
				echo 'BB CODE: [url]http://www.jandown.com/link.php?ref=' . $code . ' [/url]';
			}
		}
	}
} else {
	echo "Invalid file [.torrent] <br>";
	
	echo $_FILES ["file"] ["type"] . '<br>';
	
	echo $_FILES ["file"] ["size"];
}
?>








</body>
</html>